﻿using BLL.Entities;
using BLL.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DbFactory
{
    class UserFactory
    {
        internal static User ZhangSan, LiSi;
        internal static void Create()
        {
            //张三和李四的注册
            ZhangSan = register("张三", "1234");
            LiSi = register("李四", "4321");
        }
        //因为要注册多个对象，所以可以再次抽象方法
        private static User register(string name, string password)
        {
            User user = new User { Name = name, Password = password };
            user.Register();
            UserRepository userRepository = new UserRepository(Global.GetDbContext());
            userRepository.Save(user);
            return user;
        }
    }
}
